package com.xy.blog.article.api;

import com.xy.blog.article.api.model.ArticleDTO;
import com.xy.blog.article.api.model.ArticleQuery;
import com.xy.blog.core.exception.BaseException;
import com.xy.blog.core.springmvc.controller.IBaseController;
import com.xy.blog.core.springmvc.result.page.PageReq;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author zanhonglei
 * @version V1.0
 * @Description:
 * @date 2020/5/26
 */
@FeignClient(name = "xy-blog-article-center",contextId = "ArticleService")
public interface ArticleService extends IBaseController<ArticleQuery, ArticleDTO> {

    String BASE_PATH = "/v1/article";

    @Override
    @PostMapping(BASE_PATH + "/pages")
    Object pages(@RequestBody PageReq<ArticleQuery> req) throws BaseException;

    @Override
    @GetMapping(BASE_PATH)
    Object getById(@RequestParam Long id) throws BaseException;

    @Override
    @PostMapping(BASE_PATH)
    Object save(@Valid @RequestBody ArticleDTO req) throws BaseException;

    @Override
    @PutMapping(BASE_PATH)
    Object update(@Valid @RequestBody ArticleDTO req) throws BaseException;

    @Override
    @DeleteMapping(BASE_PATH)
    Object deleteById(@RequestParam Long id) throws BaseException;

    /**
     * 赞
     * @param id
     * @return
     * @throws BaseException
     */
    @GetMapping(BASE_PATH + "like")
    Object like(@RequestParam Long id) throws BaseException;

    /**
     * 浏览量
     * @param id
     * @return
     * @throws BaseException
     */
    @GetMapping(BASE_PATH + "view")
    Object view(@RequestParam Long id) throws BaseException;

    /**
     * 修改文章排序
     * @param oldId
     * @param newId
     * @return
     */
    @GetMapping(BASE_PATH + "/change-orders")
    public Object changeOrders(@RequestParam String oldId,@RequestParam String newId);


}
